<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2019/3/18
 * Time: 8:45
 */

namespace Home\Controller;


use Think\Controller;

class ExamController extends Controller
{
      public function First_one(){
          $sum = 0;
          for ($i=1;$i<=100;$i++){

              $sum += $i;

          }
          print_r($sum);
      }

      public function First_two(){

          $num = 100;

          $dou = $num/2;

          $sum = 101*$dou;

          print_r($sum);
      }

      public function First_three(){

          $arr = [];

          $i = 0;

          for ($i=1;$i<=100;$i++){

              $arr[] = $i;

          }
          $sum = array_sum($arr);
      }

      public function Second_one(){

          $num = 5;

          $sum = 1;

          for ($i = 0 ; $i<=$num ; $i++){

              $sum = $sum*($num);
              $num--;
          }
          print_r($sum);
      }

      public function Second_two(){

          $num = 5;
          $sum = $this->digui($num);
      }

      function digui($num,$sum = 1){

          $sum = $sum*($num);
          $num--;
          if($num > 1){
              $this->digui($num,$sum);
          }else
          {
              echo $sum;
          }
      }

      public function Three(){

          $str = 'abba';

          $num = strlen($str);

          $status = '';

          for ($i=0;$i<$num;$i++){
              if($str[$i] == $str[$num-1]){
                  $num--;
                  $status = true;
              }else
              {
                  $status = false;
              }
          }

      }
}